package vn.personal.anhht.bloback12.adapter;

import java.util.List;

import vn.personal.anhht.bloback12.activity.R;
import vn.personal.anhht.bloback12.bean.ContactObject;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;


public class ContactsAdapter extends ArrayAdapter<ContactObject>{

	
	private List<ContactObject> items;
	public ContactsAdapter(Context context, int textViewResourceId,
			List<ContactObject> items) {
		super(context, textViewResourceId, items);
		
		this.items = items;
		
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.custom_row_contact, null);
        }
        final ContactObject item = items.get(position);
        if(item != null){
        	TextView tvName = (TextView)v.findViewById(R.id.tv_pcontact_name);
        	if(tvName != null) tvName.setText(item.getName());
        	TextView tvPhone = (TextView)v.findViewById(R.id.tv_pcontact_phone);
        	if(tvPhone != null) tvPhone.setText(item.getPhone());
        	//ImageView iv = (ImageView)v.findViewById(R.id.iv_pcontact_contact);
        	
    		//iv.setImageResource(R.drawable.ic_incall);
    		//iv.setImageResource(android.R.drawable.sym_call_incoming);
        	/*final ImageView iv = (ImageView)v.findViewById(R.id.iv_pcontact_contact);
        	//iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_arrow));
        	iv.setImageResource(R.drawable.ic_arrow);*/
        	/*CheckBox cbSelect = (CheckBox)v.findViewById(R.id.cb_select);
        	
        	cbSelect.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					
					CheckBox cbox = (CheckBox)v.findViewById(R.id.cb_select);
					if(cbox.isChecked()){
						selectedItems.add(item);
						Toast.makeText(v.getContext(), selectedItems.size() + "__sdfaf" + item.getName(), Toast.LENGTH_SHORT).show();
					}else{
						selectedItems.remove(item);
						Toast.makeText(v.getContext(), selectedItems.size() + "__sdfaf" + item.getPhone(), Toast.LENGTH_SHORT).show();
					}
				}
        		
        	});*/
        }
		
		
		return v;
		
	}

	

}
